home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / novell / appl1.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  9KB  |  255 lines

  1. /************************* APPL1 ****************************/
  2. #include <include.h>         /* @0224 */
  3. #include <memory.h>
  4. #include <string.h>
  5. #include <malloc.h>
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <state1.h>
  9. #define RESRU 19
  10. #define RESRH 16
  11. extern struct segprf *preqseg(int );
  12. extern struct rqb *preqrq(int );
  13. extern unsigned long findnau(void *,void **);
  14. extern void pattach(int ,char far *,int );
  15. extern void prelseg(struct segprf *);
  16. extern int totalNau;
  17. extern struct nau naua[100];
  18.  
  19. struct hscb *crhscb( char *, char *);
  20. struct hscb *findhscb( unsigned long  );
  21. struct rqb *memget( struct rqb *);
  22. struct rqb *rqopndst( struct rqb *);
  23. struct rqb *send( struct rqb *);
  24. struct rqb *rqclsdst( struct rqb *);
  25. struct rqb *exname( struct rqb *);
  26. struct rqb *dtlu( struct rqb *);
  27. struct rqb *memget(struct rqb *);
  28.  
  29.  
  30.      struct rqb *appl1(struct rqb *wrqbg)
  31.      {
  32.         char parm;
  33.         parm=wrqbg->th.ra.rparm.parm.parm1;
  34.         switch (parm) {
  35.         case 0: return(rqopndst(wrqbg));
  36.         case 1: return(send(wrqbg));
  37.         case 3: return(rqclsdst (wrqbg));
  38.             case 5: return(memget(wrqbg)); /* only for DOS */
  39.             case 6: return(exname(wrqbg));
  40.             case 7: return(dtlu(wrqbg));
  41.             default:
  42.          return (NULL);
  43.                       }
  44.  
  45.  }/**************** end of appl1 *********************************/
  46. /********************** EXNAME ***********************************/
  47. struct rqb *exname(struct rqb *wrqb)
  48.        {
  49.         struct nau *wnau;
  50.         unsigned long rc;
  51.  
  52.               wnau = &naua[0];
  53.               memcpy(wnau -> name,&(wrqb->th.ra.wa.area[0]),8);
  54.               pattach(0,NULL,0);
  55.               wnau -> flag |= NAUACTIV;  /* @2070 */
  56.               return(wrqb);
  57.        }
  58.  /****************************************************************/
  59.  /********************* MEMGET ***********************************/
  60.  struct rqb *memget(struct rqb *wrqb)
  61.        {
  62.          struct segprf *wseg;
  63.          struct rqb *wrqbn;
  64.              if (wrqb->th.ra.wa.rqba.rsrlen == 0)
  65.                      wrqb->th.ra.wa.rqba.area1=preqrq(1);
  66.               else
  67.                     {wseg=preqseg(wrqb->th.ra.wa.rqba.rsrlen);
  68.                      if (wseg==NULL) {
  69.                         wrqb->th.ra.wa.rqba.area1=NULL;
  70.              }
  71.                       else
  72.             { wrqbn=(char *)wseg+12;         /* 5001 */
  73.                           wrqb->th.ra.wa.rqba.area1=wrqbn;
  74.                         }
  75.                      }
  76.          wrqb->th.ra.code|=FROM;
  77.          return(wrqb);
  78.        }
  79.  /***************** end of memget ********************************/
  80. /********************** DTLU ***********************************/
  81. struct rqb *dtlu(struct rqb *wrqb)                      /* 2071 */
  82.        {                                                     /* 2071 */
  83.         struct nau *wnau;                                    /* 2071 */
  84.         unsigned long rc;                                    /* 2071 */
  85.                                                              /* 2071 */
  86.               rc=findnau(&(wrqb->th.ra.wa.area[0]),&wnau);   /* 2071 */
  87.               if (rc == 0) {                                 /* 2071 */
  88.                      wnau->flag &= 0x7f;                     /* 2071 */
  89.                      pattach(3,NULL,0);
  90.                      return(wrqb);                           /* 2071 */
  91.            }                                                 /* 2071 */
  92.               return (NULL);                                 /* 2071 */
  93.        }                                                     /* 2071 */
  94.  /****************************************************************/
  95.  /******************** OPNDST ************************************/
  96.  struct rqb *rqopndst (struct rqb *wrqbg)
  97. {
  98.     struct nib *wnib;
  99.     unsigned long rc;
  100.     struct nau *wnau;
  101.     struct nau *wnaupt;
  102.     struct segprf *wsegb;
  103.     struct rqb *wrqbb,*wrqbq;
  104.     struct bind *wbind;
  105.     struct rh *wrhb;
  106.     struct th *wthb;
  107.     struct hscb *whscb;
  108.     union ru *wru;
  109.     short i;
  110.     char *p, *t_wnib;
  111.      char bindhdr[3];
  112.  
  113.  
  114.      bindhdr[0]=0x6B;
  115.      bindhdr[1]=0x80;
  116.      bindhdr[2]=0x01;
  117.  
  118.     wru=(char*)wrqbg+RESRU;
  119.     if ((t_wnib=preqseg(sizeof(struct nib)-16)) == NULL) /* 5001 */
  120.  
  121.       {
  122.      return 0;
  123.       }
  124.     wnib=t_wnib+12;                        /* 5001 */
  125.     memcpy(wnib,wru,sizeof(struct nib));   /* 5001 */
  126.     rc=findnau(wnib->mode,&wnau);
  127.     if (rc != 0)
  128.                return (NULL);
  129.      if((whscb=crhscb( wnib->mode,wnib->sym)) == NULL)
  130.             goto BADRSP;
  131.      wsegb=preqseg(sizeof(struct bind)+3);     /*1350*/ /*5002*/
  132.      if (wsegb==NULL) {
  133.           return 0;}
  134.      wrqbb=(struct rqb *)((char*)wsegb+12);
  135.      wrhb=(char*)wrqbb+RESRH;
  136.      for (i=0;i<3;i++)
  137.        wrhb->rh[i]=bindhdr[i];
  138.      wbind=(char*)wrqbb+RESRU;
  139.      wbind->cmd=0x31;
  140.      wbind->bim.old.type=0x01;
  141.      wbind->crypt=0;
  142.      wbind->plulen=0x10;
  143.      wbind->slulen=0x10;
  144.        memcpy (wbind->plu,wnib->mode,8);       /* 1075 */
  145.        memcpy (wbind->slu,wnib->sym,8);       /* 1075 */
  146.        wbind->urclen=0x00;
  147.        wbind->usrlen=0x00;
  148.     memcpy (&(wrqbg->th.ra.wa.hh.rswa),&(wnib->user),4);
  149.     memcpy(&(wrqbg->th.ra.wa.area[0]),&(wnau->sid),2); /* @2005 */
  150.  
  151.     if(wnau->opnq==NULL)   /*place OPNDST RQB in queue*/
  152.            {wnau->opnq=wrqbg;
  153.             goto PATT;
  154.            }
  155.     wrqbq=wnau->opnq;
  156.     while(wrqbq->link!=NULL)
  157.             wrqbq=wrqbq->link;
  158.     wrqbq->link=wrqbg;
  159.     PATT:
  160.     p = wnib;
  161.     memset(p + 8, 0, 8);
  162.     prelseg(t_wnib);
  163.      wrqbb->th.ra.wa.hh.hscb=whscb;
  164.      wrqbb->th.ra.rparm.parm.parm1=0x08;
  165.      wthb=&(wrqbb->th.th);
  166.     memcpy(&(wthb->t912.old.snf),&(wnau->sid),2); /* @2005 */
  167.     wnau->sid++;
  168.      wthb->t912.old.dcf=(sizeof(struct bind)+3);     /*@2003 */
  169.      wthb->t13.lan.fid=FID8+EFI;         /* @0172 */
  170.      wthb->t13.lan.fid |= 0x0c;          /* 1068 */
  171.      wrhb=(char*)wrqbb+RESRH;
  172.      wrhb->rh[2]|=0x01;
  173.      wrqbb->th.ra.stcb=SESSA_CODE;
  174.      wrqbb->th.ra.code=0x02;
  175.      wrqbb->th.ra.code|=FROM;
  176.      wsegb->len = wthb -> t912.old.dcf;
  177.      memcpy(wsegb->net_ad,whscb->part_net_ad,6);
  178.      pattach(1,wrqbb,wthb->t912.old.dcf);
  179.      return (wrqbg);
  180.     BADRSP:
  181.          /*building response RQB for LU62*/
  182.          wrqbg->th.ra.stcb=wrqbg->th.ra.wa.rqba.rsrlen+ST_N;
  183.      memcpy (&(wrqbg->th.ra.wa.hh.rswa),&(wnib->user),4);
  184.          wrqbg->th.ra.rparm.parm.parm1=5;
  185.          wrqbg->th.ra.rparm.parm.parm2=0xff;
  186.          wrqbg->th.ra.code=0xca;
  187.          return (NULL);
  188.   } /**********************end of opndst ****************************/
  189.   /*********************** SEND **************************************/
  190.   struct rqb *send (struct rqb *wrqbg)
  191.  {
  192.     struct segprf *wseg;
  193.     struct rh *wrh;
  194.     struct th *wth;
  195.     struct hscb *whscb;
  196.  
  197.     whscb = findhscb( wrqbg -> th.ra.wa.hh.hscb);
  198.     if( whscb == NULL )
  199.             return (NULL);
  200.     wseg=(struct segprf *)((char*)wrqbg-12);
  201.     wrqbg->th.ra.rparm.parm.parm1=0;       /*@2001 */
  202.     wrh=(char*)wrqbg+RESRH;
  203.     wth=&(wrqbg->th.th);           /* @2005 */
  204.     wth->t912.old.dcf=wseg->len;          /* @2005 */
  205.  
  206.     wrqbg->th.ra.stcb=DFC_CODE;
  207.     wrqbg->th.ra.code=0x02;
  208.     wrqbg->th.ra.code |= FROM;
  209.     memcpy(wseg -> net_ad,whscb -> part_net_ad,6);
  210.     pattach(1,wrqbg,wseg->len);
  211.        return (wrqbg);
  212.     } /************************** end of send ************************/
  213.     /******************** CLSDST *************************/
  214.     struct rqb *rqclsdst(struct rqb *wrqbg)
  215.     {
  216.         struct segprf *wseg;
  217.         struct rqb *wrqb;
  218.         short i;
  219.     char unbndhdr[3];
  220.         struct rh *wrh;
  221.         struct th *wth;
  222.         struct hscb *whscb;
  223.         struct unbind *wun;
  224.  
  225.         unbndhdr[0]=0x6b;
  226.     unbndhdr[1]=0x80;
  227.     unbndhdr[2]=0x01;
  228.            whscb=findhscb(wrqbg->th.ra.wa.hh.hscb);
  229.            if( whscb == NULL)
  230.                 return (NULL);
  231.            wseg=preqseg(25); /*segment request for unbind */
  232.            if (wseg==NULL)
  233.         {
  234.                   return (NULL);
  235.                 }
  236.            wrqb=(struct rqb *)((char*)wseg+12);
  237.            wrh=(char*)wrqb+RESRH;
  238.            for (i=0;i<3;i++)
  239.                 wrh->rh[i]=unbndhdr[i];
  240.            wun=(char*)wrqb+RESRU;
  241.            wun->cmd=0x32;
  242.            wun->type=0x01;
  243.            wrqb->th.ra.wa.hh.hscb=whscb->cor;
  244.            wth=&(wrqb->th.th);
  245.            wth->t13.lan.fid=0x8d;
  246.            wth->t912.old.dcf=(sizeof(struct unbind)+3);  /* @2005 */
  247.            wrqb->th.ra.stcb=SESSA_CODE;
  248.            wrqb->th.ra.code=0x02;
  249.            wrqb->th.ra.code |= FROM;
  250.            memcpy( wseg -> net_ad, whscb -> part_net_ad,6);
  251.            pattach(1,wrqb,wth->t912.old.dcf);
  252.               return ( wrqbg);
  253.    }/************************* end of clsdst ************************/
  254.   /******************* THE END ******************************************/
  255.